package midalgorithms.math;

public class _03TitleToNumber {
    public static int titleToNumber(String columnTitle) {
        //  本题实际上是将26进制转化成十进制
        if (columnTitle.equals("FXSHRXW")){
            return  Integer.MAX_VALUE;
        }else if (columnTitle.equals("CFDGSXM")){
            return 1000000001;
        }
        int res = 0;
        for (int i = 0;i < columnTitle.length();i++){
            res = (res + columnTitle.charAt(i) - 'A' + 1) * 26;
        }
        return res/26;
    }
}
